# Encoding::default_external = Encoding::GBK

# @Author  : Eliza
# @Time    : 2021/08/23 22:40
# @Software : RubyMine
$KCODE = 'u'
#字符串的比较是依据的数据本身，也就是字节。
puts "-------------"
puts 'あ' == 'あ'
puts 'あ'.encode("UTF-8")
# 采用 %q 和 %Q 来引导的字符串变量，%q 使用的是单引号引用规则，
# 而 %Q 是双引号引用规则，后面再接一个 (! [ { 等等的开始界定符和与 } ] ) 等等的末尾界定符。
#
desc1 = %Q{Ruby 的字符串可以使用 '' 和 ""。}
puts desc1

# str[position] # 注意返回的是ASCII码而不是字符 str[start, length]

abc = "abc"
puts abc.encoding.name # >> US-ASCII

abc.force_encoding("UTF-8") #强制转换
puts abc.encoding.name # >> UTF-8
# valid_encoding? 方法来看看字节能够被顺利的处理。
abc.force_encoding("GBK")
puts abc.encoding.name # >> UTF-8
puts abc.valid_encoding? # >> true
abc_encode = abc.encode("UTF-8")
abc.force_encoding("UTF-8")

puts "----------------"
puts abc.bytesize
puts abc.encoding
puts abc.each_byte { |b| print "%02X," % [b] }
puts "\x61\x62\x63" #abc
puts "あ".bytesize #3
puts "あ".each_byte { |b| print "%02X," % [b] }
puts "い".each_byte { |b| print "%02X" % [b] }
string1 = "\u30A5" #Unicode
# 允许我们使用\uXXXX指定Unicode码点对于的字符，通用也运行我们使用\xXX指定字节。
puts string1.to_s
puts string1.bytesize
puts "\u30A5" + "\u0003"

# "\u3040".."\u309F"
# # "\u30A0".."\u30FF"
ar01 = []
ar02 = []

for index in "\u3041".."\u3096" do
  # print index
  ar01.append(index)

end
puts "\n"
for index in "\u30A1".."\u30F6" do
  ar02.append(index)
  # print index
end
puts "\u309F"
puts "\u30A1"
puts "==================="
puts ar01.size, ar02.size
jpMap = {}
for key in 0..ar01.length - 1 do
  jpMap[ar01[key]] = ar02[key]

end
puts "==================="
# jpMap.each_key { |key| puts key + ":" + jpMap[key] }
puts jpMap['る'] == "ル"
puts "Enter charts"
# puts jpMap[a]=="ル
s = gets.chomp
p s